package com.sailfish.springbootdemo.dao.db7;

import com.sailfish.springbootdemo.common.DB7TableName;
import com.sailfish.springbootdemo.pojo.db7.VplColumnMeta;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface TbVplColumnMetaDao {
    @Insert({
            "<script>",
            "INSERT INTO " + DB7TableName.TB_VPL_COLUMN_META + " (meta_id, column_name, data_type) VALUES ",
            "<foreach item='col' collection='columns' separator=','>",
            "(#{metaId}, #{col.columnName}, #{col.dataType})",
            "</foreach>",
            "</script>"
    })
    int batchInsert(@Param("metaId") Integer metaId,
                    @Param("columns") List<VplColumnMeta> columns);

    @Select("SELECT * FROM " + DB7TableName.TB_VPL_COLUMN_META + " WHERE meta_id = #{metaId}")
    List<VplColumnMeta> selectByMetaId(Integer metaId);
}